// import React from "react";
import React from "./react";

const reducer = (state,action)=>{
  switch (action.type) {
    case 'ADD':
      return {number:state.number+1};
    case 'MINUS':
      return {number:state.number-1}
    default:
      return state;
  }

}

function App (){
  const [state, dispatch] = React.useReducer(reducer,{number:1})
  const [num, setNum] = React.useState(2)
  return <div>
    <p>Counter: {state.number}</p>
    <button onClick={()=>dispatch({type: 'ADD'})}>+</button>
    <button onClick={()=>dispatch({type: 'MINUS'})}>-</button>
    <button onClick={()=>setNum(num+2)}>{num}</button>
  </div>
}
export default App